package com.mid;

/**
 * Created by Lxk on 2020/2/17.
 */
public class Solution287 {

    public int findDuplicate(int[] nums) {
        if (nums.length <= 1) {
            return 0;
        }
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
        }
        int normalSum = (1 + nums.length - 1) * (nums.length - 1) / 2;
        return sum - normalSum;
    }

    public static void main(String[] args) {
        int[] arr = {3, 1, 3, 4, 2};
        Solution287 solution287 = new Solution287();
        System.out.println(solution287.findDuplicate(arr));
    }

}
